<?php

 /**
  * @package JooS
  * @subpackage Syntax_PHPackager
  */

  require_once "JooS/Syntax/Complex/Transition.php";

  abstract class JooS_Syntax_PHPackager_Instruction_Set extends JooS_Syntax_Complex_Transition {
    /**
     * @return string
     */
    abstract public function getTargetSyntaxName();

    /**
     * @return string
     */
    abstract protected function compileSet($target, $value);
    
    /**
     * @return string
     */
    public function compile() {
      $ret = parent::compile();
      if ($ret !== false) {
        $ret = $this->compileSet( $this->getRule(0)->getParsedValue(), $this->getRule(4)->getParsedValue() );
      }
      return $ret;
    }

    /**
     * @return JooS_Syntax_Complex_Concatenate
     */
    public function createRule() {
      $parser = $this->getParser();
      
      return $parser->createSyntax("Complex_Concatenate", array(
        $parser->createSyntax("Complex_Repetition", $parser->createSyntax($this->getTargetSyntaxName()), null, 1),
        $parser->createSyntax("Common_Whitespace"),
        $parser->createSyntax("Simple_Symbol", "="),
        $parser->createSyntax("Common_Whitespace"),
        $parser->createSyntax("PHPackager_Expression"),
      ));
    }
  }
